package com.song.cmsservice.controller;

import com.song.cmsservice.client.IndexFeign;
import com.song.cmsservice.client.VodFeign;
import com.song.cmsservice.entity.frontvo.CourseFrontVo;
import com.song.commonutils.ResultObj;
import feign.Feign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author song
 * @data 2020/4/6
 */
@RestController
@Api(description = "前台课程管理")
@RequestMapping("/cmsservice/course")
public class FrontCourseController {
    @Autowired
    private IndexFeign indexFeign;

    @Autowired
    private VodFeign vodFeign;

    /**
     * 分页添加查询课程
     * @param page
     * @param limit
     * @param courseFrontVo
     * @return
     */
    @ApiOperation("分页添加查询课程")
    @PostMapping("/getFrontCourseList/{page}/{limit}")
    public ResultObj getFrontCourseList(@PathVariable("page") long page, @PathVariable("limit") long limit,
                                 @RequestBody(required = false) CourseFrontVo courseFrontVo){
        return indexFeign.getFrontCourseList(page,limit,courseFrontVo);
    }


    /**
     * 课程详情的方法
     * @param courseId
     * @return
     */
    @ApiOperation("课程详情的方法")
    @GetMapping("/getFrontCourseInfo/{courseId}")
    public ResultObj getFrontCourseInfo(@PathVariable("courseId") String courseId){

        return indexFeign.getFrontCourseInfo(courseId);
    }


    /**
     * 查询所有课程
     * @return
     */
    @ApiOperation("查询所有课程")
    @GetMapping("/")
    public ResultObj findAllSubject(){
        return indexFeign.findAllSubject();
    }

    /**
     * 根据视频video_source_id获取视频凭证
     * @param id
     * @return
     */
    @ApiOperation("根据视频video_source_id获取视频凭证")
    @GetMapping("/getPlayAuth/{id}")
    ResultObj getPlayAuth(@PathVariable("id") String id){
        return vodFeign.getPlayAuth(id);
    }
}
